package com.maddyhome.idea.copyright.util;

/*
 * Copyright - Copyright notice updater for IDEA
 * Copyright (C) 2004-2005 Rick Maddy. All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiJavaFile;

public class FileInfo
{
    public FileInfo(PsiFile file)
    {
        this.file = file;
    }

    public String getPathName()
    {
        return getVirtualFile() != null ? getVirtualFile().getPath() : "";
    }

    public String getFileName()
    {
        return getVirtualFile() != null ? getVirtualFile().getName() : "";
    }

    public String getClassName()
    {
        if (file instanceof PsiJavaFile)
        {
            return ((PsiJavaFile)file).getClasses()[0].getName();
        }
        else
        {
            return getFileName();
        }
    }

    public String getQualifiedClassName()
    {
        if (file instanceof PsiJavaFile)
        {
            return ((PsiJavaFile)file).getClasses()[0].getQualifiedName();
        }
        else
        {
            return getPathName();
        }
    }

    public DateInfo getLastModified()
    {
        if (getVirtualFile() != null)
        {
            return new DateInfo(getVirtualFile().getTimeStamp());
        }
        else
        {
            return new DateInfo();
        }
    }

    private VirtualFile getVirtualFile()
    {
        return file.getVirtualFile();
    }

    private PsiFile file;
}